function w = lagrange(x,y,z)

	w = [];

	for j = 1 : length(z) 
        pn = 0;
		for i = 1 : length(x)
			pn = pn + y(i)* l_j(i,x,z(j));
		endfor
        w = [w,pn]; 
	endfor

end

function result = l_j(j,x,z_i)

    result = 1;
    for i = 1 : length(x)
        if (i != j)
            result =  result * (z_i - x(i))/(x(j) - x(i));
        endif
    endfor

end 



